<?php
/**
 * Created by PhpStorm.
 * User: ahao
 * Email: 827316006@qq.com
 * Date: 2019/12/18 22:31
 */

$chan = new Co\Channel(10);

go(function () use ($chan) {
    $chan->push(['ahao' => 'swoole']);
});

go(function () use ($chan) {
    $chan->push(['ahui' => 'xiaozhu']);
});

go(function () use ($chan) {
   $j = $chan->length();
   for ($i = 0; $i < $j; $i++) {
       print_r($chan->pop());
   }
   while (true) {
       $res = $chan->pop();
       print_r($res);
   }
});